﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using HNCDataSetTableAdapters;

public partial class Admin_Home_Video : System.Web.UI.Page
{
    ProductsTableAdapter pro = new ProductsTableAdapter();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            loadVideo(6);
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        int i = pro.UpdateProductByCateID(null, txtTitle.Text, txtTitle.Text, txtTitle.Text, txtTitle.Text, txtVideoUrl.Text, txtVideoUrl.Text, null, null, txtVideoUrl.Text, null, null, 6, DateTime.Now, DateTime.Now, "hnc", false, false, false, null, null, null, null, 1, true, false);
        if (i > 0)
        {
            lblMsg.Text = "Cập nhật thành công !";
            loadVideo(6);
        }
        else
        {
            lblMsg.Text = "Cập nhật thất bại !";
        }
    }

    public void loadVideo(int cateid)
    {
        DataTable dt = pro.GetProductByCateID(cateid);
        txtTitle.Text = dt.Rows[0]["Title"].ToString();
        txtVideoUrl.Text = dt.Rows[0]["VideoUrl"].ToString();
    }
}